<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
</head>
<body>
    <!-- constructor可以查看属于哪个原型对象 -->
    <script>
        function Person(name,age){
            this.name = name ,
            this.age = age
        }
        // 以字面量的形式为原型对象添加属性，会改变constructor属性使其变成Object
        Person.prototype = {
            constructor:Person,
            sayName:function(){
                console.log(this.name);
            },
            sayAge(){
                console.log(this.age);
            }
        }
        var p = new Person("zz",18)
        console.log('p: ', p);
        console.log(p.constructor);
        console.log(p.constructor==Person);
    </script>

    <!-- 为了解决上面的问题可以在原型里重置constructor的属性 -->
    <!--  Person.prototype = {
            constructor:Person, //这里重置
            sayName:function(){
                console.log(this.name);
            },
            sayAge(){
                console.log(this.age);
            }
        } -->
</body>
</html>